package com.gougang.interview;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 16978 on 2017/4/7.
 */
public class Test {

    public static void main(String[] args) throws Exception {
        //初始化扑克
        PokerGame pokerGame = new QiaoPaiGame();
        pokerGame.shuffle();
        pokerGame.deal();

        List<Person> users = getUsers(pokerGame, Direction.North);

        List<CardBean> eachRound = new ArrayList<CardBean>();

        int round = pokerGame.getRound();
        for (int i = 0; i < round; i++) {
            for (int j = 0; j < users.size(); j++) {
                CardBean first = users.get(j).play();
            }
        }


        System.out.println("done");


    }

    private static List<Person> getUsers(PokerGame pokerGame,Direction direction) {
        List<CardBean> listEast = new ArrayList<CardBean>(pokerGame.getCards("east"));
        List<CardBean> listWest = new ArrayList<CardBean>(pokerGame.getCards("west"));
        List<CardBean> listSouth = new ArrayList<CardBean>(pokerGame.getCards("south"));
        List<CardBean> listNorth = new ArrayList<CardBean>(pokerGame.getCards("north"));


        //创建玩家
        Person pEast = new Person();
        pEast.setHoldPokers(listEast);
        pEast.setTeam("A");
        pEast.setDirection(Direction.East);

        Person pWest = new Person();
        pWest.setHoldPokers(listWest);
        pWest.setTeam("A");
        pWest.setDirection(Direction.West);

        Person pSouth = new Person();
        pSouth.setHoldPokers(listSouth);
        pSouth.setTeam("B");
        pSouth.setDirection(Direction.South);

        Person pNorth = new Person();
        pNorth.setHoldPokers(listNorth);
        pNorth.setTeam("B");
        pNorth.setDirection(Direction.North);

        List<Person> persons = new ArrayList<Person>();
        switch (direction){
            case North:
                persons.add(pNorth);
                persons.add(pEast);
                persons.add(pSouth);
                persons.add(pWest);
                break;
            case South:
                persons.add(pSouth);
                persons.add(pWest);
                persons.add(pNorth);
                persons.add(pEast);
                break;
            case East:
                persons.add(pEast);
                persons.add(pSouth);
                persons.add(pWest);
                persons.add(pNorth);
                break;
            case West:
                persons.add(pWest);
                persons.add(pNorth);
                persons.add(pEast);
                persons.add(pSouth);
                break;
            default:
                persons.add(pEast);
                persons.add(pSouth);
                persons.add(pWest);
                persons.add(pNorth);
        }
        return persons;
    }
}
